package de.lns.entities.effect;

import de.lns.entities.Entity;
import de.lns.entities.mobs.Mob;
import de.lns.tick.UpdateThread;
/**
 * 
 * @author Jascha
 *
 */
public class Damageeffect extends TimedEffect {
	private Damage damage;
	private double dmgamount;
	private double dpms;
	private double critchance;
	private Mob mob;
	
	/**
	 * 
	 * @param entity The Mob this effect should be applied on.
	 * @param time The time this effect should last.
	 * @param damage The damage type this effect should deal.
	 * @param dmgamount The amount of damage this effect should deal.
	 * @param critchance The Critchance of this effect.
	 */
	public Damageeffect(Effectable entity, int time, Damage damage, double dmgamount, double critchance) {
		super(entity, time);
		this.mob=(Mob) entity;
		this.critchance=critchance;
		this.damage=damage;
		this.dmgamount=dmgamount;
		this.dpms=dmgamount/time;
	}
//	@Override
//	public void setEntity(Effectable entity){
//		this.mob=(Mob) entity;
//		this.entity=entity;
//		System.out.println(entity);
//	}
	@Override
	/**
	 * The actual damage calculation.
	 */
	public void update(){
		boolean crit = false;
		if(Math.random()*100<critchance)
			crit=true;
		this.mob.getDamage(damage, UpdateThread.getDelta()*dpms, crit);
		super.update();
		//Exception e = new Exception();
		//e.printStackTrace();
	}
	@Override
	protected void remove() {
	return;
	}

}
